        package DAL;

        import java.util.*;
        
        import DBUtil.SQLUtil;
        
        public class Schedule {

		//获取赛程表信息列表
		public List<Object> getEntity()
		{
			String sqlCmd="select *from Schedule";
			return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
		}
            
               //获取分页后赛程表信息列表
		public List<Object> getEntity(int page)
		{
			int size=(page-1)*15;
			String sqlCmd="select *from V_Schedule ORDER BY MathId  limit "+size+",15";
			return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
		}
                
               //根据查询条件sqlWhere获取分页后赛程表信息列表
		public List<Object> getEntityByWhere(String sqlWhere,int page)
		{
			int size=(page-1)*15;
			String sqlCmd="select *from V_Schedule where "+sqlWhere+" limit "+ size+",15";
			return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
        }
        
        //删除赛程表信息
        public int deleteEntity(String SchId)
        {
            String sqlCmd="delete from Schedule where SchId='"+SchId+"'";
            return DBUtil.SQLUtil.executeNonQuery(sqlCmd, null);//执行非查询操作executeNonQuery
        }
        
        //根据赛程表编号获取赛程表信息
        public List<Object> getEntityById(String SchId)
        {
            String sqlCmd="select *From V_Schedule where SchId='"+SchId+"'";
            return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
        }
        
        //更新赛程表信息
        public int updateEntity(String SchId,String PlayerId,String MathId,String IsLimit,String sequence)
        {
            String sqlCmd="Update Schedule set PlayerId='" + PlayerId + "',MathId='" + MathId + "',IsLimit='" + IsLimit + "',sequence='" + sequence + "' where SchId='"+SchId+"'";
            return SQLUtil.executeNonQuery(sqlCmd, null);
        }
        
        //插入赛程表信息
        public int insertEntity(String SchId,String PlayerId,String MathId,String IsLimit,String sequence)
        {
            String sqlCmd="Insert into Schedule values('" + SchId + "','" + PlayerId + "','" + MathId + "','" + IsLimit + "','"+sequence+"')";
            return SQLUtil.executeNonQuery(sqlCmd, null);
        }
        
        //检查插入主键是否重复
        public boolean checkExist(String SchId)
        {
            String sqlCmd="select count(*) from Schedule where SchId='"+SchId+"'";
            if(1==Integer.parseInt(SQLUtil.excuteScalar(sqlCmd, null).toString()) )
            {
                return true;
            }
            return false;
        }

		//获取分页总数
		public Object getPageCount()
		{
			String sqlCmd="SELECT CEIL( COUNT(*)/15.0) FROM V_Schedule ";
			return SQLUtil.excuteScalar(sqlCmd, null);
		}

		//根据查询条件获取分页总数
		public Object getPageCountByWhere(String sqlWhere)
		{
			String sqlCmd="SELECT CEIL( COUNT(*)/15.0) FROM V_Schedule where "+sqlWhere;
			return SQLUtil.excuteScalar(sqlCmd, null);
		}
            
        }
